#include "orangepch.h"
#include "OrthogonalCamera.h"
#include "glm/gtc/matrix_transform.hpp"

namespace Orange {
	OrthogonalCamera::OrthogonalCamera(float left, float right, float bottom, float top) :
		m_PrejectMatrix(glm::ortho(left, right, bottom, top, -1.0f, 1.0f)),m_ViewMatrix(1.0f)
	{
		m_ViewPrejectMatrix = m_PrejectMatrix * m_ViewMatrix;
	}
	void OrthogonalCamera::SetPrejectMatrix(float left, float right, float bottom, float top) {
		m_PrejectMatrix = glm::ortho(left, right, bottom, top, -1.0f, 1.0f);
		m_ViewPrejectMatrix = m_PrejectMatrix * m_ViewMatrix;
	}


	void OrthogonalCamera::CalculatePrejectViewMatrix()
	{
		glm::mat4 transform = glm::translate(glm::mat4(1.0f), m_Position) * glm::rotate(glm::mat4(1.0f), glm::radians(m_Rotation), glm::vec3(0, 0, 1));
		
		// ��ͼ�� ����෴�� �����ƶ� �ﵽ �ƶ������ Ч��
		m_ViewMatrix = glm::inverse(transform);

		m_ViewPrejectMatrix = m_PrejectMatrix * m_ViewMatrix;
	}

}